package com.estate.business.impl;

import java.util.List;

import com.estate.business.TenderCopyService;
import com.estate.dao.TenderCopyDao;
import com.estate.vo.Vo;
import com.estate.vo.impl.TenderCopyVo;

public class TenderCopyServiceImpl implements TenderCopyService {

	private TenderCopyDao tenderCopyDao;

	public TenderCopyDao getTenderCopyDao() {
		return tenderCopyDao;
	}

	public void setTenderCopyDao(TenderCopyDao tenderCopyDao) {
		this.tenderCopyDao = tenderCopyDao;
	}
	
	public boolean addTenderCopy(TenderCopyVo tenderCopy) {
		boolean result =false; 
		result = this.getTenderCopyDao().addVo(tenderCopy);
		return result;
	}

	public List<Vo> getList() {
		List<Vo> allList = this.getTenderCopyDao().findAll();
		return allList;
	}

	public TenderCopyVo getTenderCopy(int id){
		TenderCopyVo project = (TenderCopyVo) this.getTenderCopyDao().findByPK(id);
		return project;
	}

	public boolean updateTenderCopy(TenderCopyVo tenderCopy){
		boolean result =false;
		TenderCopyVo old = this.getTenderCopy(tenderCopy.getId());
		tenderCopy.setPostDate(old.getPostDate());
		tenderCopy.setPostUser(old.getPostUser());
		tenderCopy.setTender(old.getTender());
		result = this.getTenderCopyDao().updateVo(tenderCopy);
		return true;
	}
	
	public boolean deleteMultiTenderCopy(String delStr){
		if(delStr!= null && !"".equals(delStr) && !",".equals(delStr)){
			String[] delArray = delStr.split(",");
			TenderCopyVo tenderCopy = null;
			for(int i = 0;i<delArray.length;i++){
				tenderCopy = new TenderCopyVo();
				tenderCopy.setId(Integer.parseInt(delArray[i]));
				this.deleteTenderCopy(tenderCopy);
			}
		}
		return true;
	}
	
	public boolean deleteTenderCopy(TenderCopyVo tenderCopy){
		boolean result = false;
		result = this.getTenderCopyDao().deleteVo(tenderCopy);
		return result;
	}
}
